	
	//전체게시판/내가쓴글 
	function clsClubAlbumList_Title(){
		this._HTMLDom = null;
		this._init();		
	}
	
	clsClubAlbumList_Title.prototype = {
		_init: function(){
			var $layer = $("section#club_album_list>section div.tab_menu ");
			this._HTMLDom = {
				"$layer": $layer
			};			
			this.setIdx(0);
			this.getValue();
		}
		, $getTab: function(){
			return this._HTMLDom["$layer"].find("ul li");
		}
		, setIdx: function(n){
			var $layer = this._HTMLDom["$layer"].find("ul li");
			$layer.removeClass("on").eq(n).addClass("on");
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"].find("ul li");
			return $layer.index($layer.filter(".on"));
		}
		, $getBtnWrite: function(){
			return this._HTMLDom["$layer"].find("p.bt a");
		}
	}
	
	//검색종류
	function clsClubAlbumList_SType(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsClubAlbumList_SType.prototype = {
		_init: function(){
			var $layer = $("section#club_album_list>section div form div select");
			this._HTMLDom = {
				"$layer": $layer	
			};
			this.listData = [{
				"코드": 0
				, "텍스트": "전체"
			}
			, {
				"코드": 1
				, "텍스트": "제목"
			}
			, {
				"코드": 2
				, "텍스트": "닉네임"
			}]
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];	
			
			$layer.empty();
			
			for(var i=0;i<this.listData.length;++i){
				$layer.append("<option>"+ this.listData[i]["텍스트"] +"</option>");	
			}
			
			$layer.selectmenu("refresh");
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];			
			var n = $layer.find("option").index($layer.find("option:selected"));	
			return n;
		}
		, $getSelect: function(){
			return this._HTMLDom["$layer"];	
		}
	}
	
	//검색어
	function clsClubAlbumList_SText(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsClubAlbumList_SText.prototype = {
		_init: function(){
			var $layer = $("section#club_album_list>section div form div");
			this._HTMLDom = {
				"$layer": $layer	
			}				
			$layer.find("input:text").val("");
		}	
		, $getBtnSearch: function(){
			return this._HTMLDom["$layer"].find("div.ser_btn");
		}
		, getValue: function(){
			var $layer = this._HTMLDom["$layer"];
			return $layer.find("input:text").val();	
		}
	}
	
	//게시판목록
	function clsClubAlbumList_List(){
		this._HTMLDom = null;
		this.listData = null;
		this.page = null;
		this._init();
	}
	
	clsClubAlbumList_List.prototype = {
		_init: function(){
			var $layer = $("section#club_album_list>section ul.club_album_list");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find(">li:eq(1)")
				, "$empty": $layer.find(">li:eq(0)")
			}			
			$layer.empty();
		}
		, setList: function(thisData){
			if(!this.listData) this.listData = [];	
			this.push(thisData);
		}	
		, push: function(thisData){
			var thisClass = this;
			var $element = this._HTMLDom["$element"];
			var $tmp = [];
		
			for(var i=0;i<thisData.length;++i){
				$tmp.push($element.clone(true));
				$tmp[i].find("img").attr("src", _util.getDefaultImage(thisData[i]["게시판이미지"]));
				$tmp[i].find("li.sub").html(thisData[i]["제목"]);
       		$tmp[i].find("li.nickname").html(thisData[i]["작성자"]["닉네임"]);
       		$tmp[i].find("li.con mark:eq(0)").html("("+ thisData[i]["나이스샷"] +")");
       		$tmp[i].find("li.con mark:eq(1)").html("("+ thisData[i]["댓글수"] +")");
       		$tmp[i].find("li.date").html(_util.fDateYmd(thisData[i]["작성일"])+"&nbsp;"+_util.fTime(thisData[i]["작성시간"]));
				thisClass.listData.push(thisData[i]);
			}
			
			this.display($tmp);
		}
		, display: function(thisData){
			var $layer = this._HTMLDom["$layer"];
					
			for(var i=0;i<thisData.length;++i){
				$layer.append(thisData[i]);	
			}
			
			if(!this.listData.length) {				
				$layer.append(this._HTMLDom["$empty"]);
			}
		}
		, reset: function(){
			this.listData = [];			
			this._HTMLDom["$layer"].empty();
		}
		, $getBtnMore: function(){		
			return this._HTMLDom["$layer"].parent().parent().find("div.btn_more");
		}
		, $getLayer: function(){			
			return this._HTMLDom["$layer"];
		}
		, getListCount: function(){
			if(!this.listData) return 0;
			return this.listData.length;
		}
	}
	
	//데이터연동		
	function clsComm_ClubAlbumList(){		
		this.clubAlbumList = null;
		this.clubAlbumListRequest = null;
		this.clubAlbumListPageData = null;
		
		this._init();
	}	
	clsComm_ClubAlbumList.prototype = {
		_init: function(){
			this.clubAlbumListRequest = {
				 "동호회키":null
				, "페이지": null
				, "내글": null					
				, "검색종류":null
				, "검색어":null
			}
	
			this.clubAlbumListPageData = {
				"현재페이지": null
				, "전체수": null
				//, "페이지당수": 10
				//, "블럭당페이지": 1
			}
		}
//------------------------ 게시판글목록------------------------//		
		, getClubAlbumList: function(){
			var thisClass = this;
			
			var szClubSeq = this.clubAlbumListRequest["동호회키"];
			var szServicename = (this.clubAlbumListRequest["내글"]?"getClubBoardMyList": "getClubBoardList");
			var szPage = this.clubAlbumListRequest["페이지"];
			var szText = this.clubAlbumListRequest["검색어"];
			
			var szAll = "";
			var szContent = "";
			var szNickName = "";	
			
			switch(this.clubAlbumListRequest["검색종류"]){
				case 0:  szAll = szText; break; //전체
				case 1:  szContent =  szText; break;//제목+내용
				case 2:  szNickName	= szText; break;//작성자
			}		
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "CB001");
        	objJson.putPub("servicename",szServicename);   
        	objJson.putPub("listcount", 10);   
        	objJson.putPub("currpageno", szPage);   
        					
        	objJson.putParameter("club_seq", szClubSeq);
        	objJson.putParameter("board_type", "P");
        	objJson.putParameter("title", "");
        	objJson.putParameter("content", szContent);
        	objJson.putParameter("reg_nickname", szNickName);
        	objJson.putParameter("search", szAll);
			
			cm.requestGet(objJson.getJsonString(), function(ret){
				thisClass.clubAlbumList = [];
				
				var items = ret["msp"]["contents"]["items"]
				
				thisClass.clubAlbumListPageData["전체수"] = ret["msp"]["contents"]["@totalcount"];
				
				if(items){		
					if(!items.length){
						items	= new Array(items);
					}					
					for(var i=0;i<items.length;i++){													
						var obj = items[i];
						thisClass.clubAlbumList.push({
						"삭제권한": _util.nvl(obj["my__article__yn"])
						, "동호회키": _util.nvl(obj["club__seq"])
						, "게시판키": _util.nvl(obj["board__seq"])
						, "제목": _util.nvl(obj["title"])
						, "댓글수": _util.nvl(obj["cr__cnt"])
						, "작성자": {
												  "이미지": _util.nvl(obj["user__image"])
												, "닉네임": _util.nvl(obj["reg__nickname"])
												, "아이디": _util.nvl(obj["reg__id"])
												}
						, "작성일":   _util.nvl(obj["reg__date"])
						, "작성시간":   _util.nvl(obj["reg__time"])
						, "조회수": _util.nvl(obj["hit"])
						, "나이스샷": _util.nvl(obj["niceshot"])
						, "공개유무": _util.nvl(obj["view__type"])
						, "게시판이미지": _util.nvl(obj["filepath"])
						, "프로필": []
						});						
					}
				}
				$(thisClass).trigger("evtFinishClubAlbumList" );
			}, function($err) {
				alert($err);
			});	
		}
		, getClubAlbumListData: function(){
			return this.clubAlbumList;
		}
		, getClubAlbumListPageData: function(){
			return this.clubAlbumListPageData;
		}
		, setClubAlbumListRequest: function(key, val){
			this.clubAlbumListRequest[key] = val;
		}
		, getClubAlbumListRequest: function(key){
			return this.clubAlbumListRequest[key];
		}	
//------------------------ 게시판글목록------------------------//			
	}
	
	//컨트롤파일
	function ClubAlbumList(){				
		this.objComm = null;
		this.club_seq = null;	
		this.club_info = null;		
		
		this.objClubSType = null;		
		this.objClubSText = null;
		this.objClubAlbumList_Title = null;
		this.objClubAlbumList_List = null;
	};
	
	ClubAlbumList.prototype = {
	    onPageShow : function() {	    
	    	$("a").attr("href", "").attr("data-rel", "");      
	    	this._init();	    		    	
	    }
	    , _beforeStart: function(){
	    	var 	thisClass = this;
	    	
	    	this._permitStart = {
				"동호회정보": false	
			}
			
	  		// 서버 메시지맵
			$.ajax({
				url: "../js/src/club/club_inc.js"
				, type: "get"
				, dataType: "script"
				, async: false
				, success: function(ret, sta){
					//alert("success!!");					
				}
				, error:function(e){
					alert("error=" + e);
				}	
			});
			
			_cb.getClubInfoData({
				"콜백": function(ret, l){
					thisClass._permitStart["동호회정보"] = true;	
				}
			});
			
			_util.executeThread(function(){
				for(key in thisClass._permitStart){		
					if(!thisClass._permitStart[key]) return false;
				}
				return (true);
			}, function(){			
				thisClass._start();
			});
	    }
	    , _init: function(){	    	    	
	    		    	
	    	this.objComm = new clsComm_ClubAlbumList();
	    	this.objClubSType = new clsClubAlbumList_SType();
	    	this.objClubSText = new clsClubAlbumList_SText();
			this.objClubAlbumList_Title = new clsClubAlbumList_Title();
			this.objClubAlbumList_List = new clsClubAlbumList_List();
			
	      this.getParam();
	      
	      this._beforeStart();
	    	
	    	this._role();
	       
	      	this._bind();	 
	      	this._eventFinish();     	
	    }
	    , _start: function(){	    	
	    	//동호회기본정보
	    	this.club_info = _cb.getClubInfo();
	    	
	    	//게시글목록
	    	this.spinStart();
			this.objComm.setClubAlbumListRequest("동호회키", this.club_seq);
			this.objComm.setClubAlbumListRequest("내글", this.objClubAlbumList_Title.getValue());
			this.objComm.setClubAlbumListRequest("페이지", 1);
			this.objComm.setClubAlbumListRequest("검색종류", this.objClubSType.getValue());
			this.objComm.setClubAlbumListRequest("검색어", this.objClubSText.getValue());
	    	this.objComm.getClubAlbumList();
	    }
	    , _eventFinish: function(){
	    	var thisClass = this;
	    	
	    	//동호회 글목록조회  완료 이벤트 
			$(this.objComm).bind("evtFinishClubAlbumList", function(){
				var thisData = thisClass.objComm.getClubAlbumListData();
				var totalCnt = thisClass.objComm.getClubAlbumListPageData();				
				thisClass.objClubAlbumList_List.setList(thisData);
				thisClass.spinEnd();
				
				//더보기 버튼 
		 		if(thisClass.objClubAlbumList_List.getListCount() >= totalCnt["전체수"]) {
		 			thisClass.objClubAlbumList_List.$getBtnMore().hide();
		 		}else {
		 			thisClass.objClubAlbumList_List.$getBtnMore().show();
		 		}
			});
	    }
		 , _bind: function(){
		 	var thisClass = this;
		 	
		 	//더보기
		 	this.objClubAlbumList_List.$getBtnMore().click(function(event){
		 		event.preventDefault();
		 		var page = thisClass.objComm.getClubAlbumListRequest("페이지");
		 		thisClass.objComm.setClubAlbumListRequest("페이지",(page+1));
		 		thisClass.objComm.getClubAlbumList();
		 		thisClass.spinStart();
		 	});
		 	
		 	//상세보기
		 	this.objClubAlbumList_List.$getLayer().on("click", "a", function(event){
		 		event.preventDefault();
		 		var n = thisClass.objClubAlbumList_List.$getLayer().find("a").index($(this));
		 						
				if(!thisClass.club_info.isOpenView(thisClass.objClubAlbumList_List.listData[n]["공개유무"])){
					alert(thisClass.club_info.getError());
					return;
				}
				
		 		_gf.CLUB_DATA = {
		 			"동호회키": thisClass.club_seq
		 			, "게시판키": thisClass.objClubAlbumList_List.listData[n]["게시판키"]
		 		}
		 		$.mobile.changePage("club_album_view.html","slide",true);
		 	});
		 	
		 	//글쓰기
		 	this.objClubAlbumList_Title.$getBtnWrite().click(function(event){
		 		event.preventDefault();		 				 		
		 		
		 		if(!_util.getLogin("아이디")){
		 			_gf.CLUB_DATA["내글"] = (thisClass.objClubAlbumList_Title.getValue()?"Y":"N");
		 			thisClass.goLogin();
		 			return;
		 		}
		 		
		 		_gf.CLUB_DATA = {
		 			"동호회키": thisClass.club_seq
		 		}
		 		$.mobile.changePage("club_album_write.html","slide",true);
		 	});
		 	
		 	//탭메뉴
		 	this.objClubAlbumList_Title.$getTab().click(function(event){
		 		event.preventDefault();
		 		var n = thisClass.objClubAlbumList_Title.$getTab().index($(this));		 		
		 		thisClass.objClubAlbumList_Title.setIdx(n);
		 		
		 		if(n==1){
			 		if(!_util.getLogin("아이디")){
			 			_gf.CLUB_DATA["내글"] = "Y";
			 			thisClass.goLogin();
			 			return;
			 		}		 					 		
			 	}
			 	
		 		thisClass.objClubAlbumList_List.reset();
		 		thisClass.objComm.setClubAlbumListRequest("내글", thisClass.objClubAlbumList_Title.getValue());
		 		thisClass.objComm.setClubAlbumListRequest("페이지", 1);
		 		thisClass.objComm.getClubAlbumList();
		 	});
		 	
		 	//검색버튼 이벤트
		 	this.objClubSText.$getBtnSearch().click(function(event){		 		
		 		event.preventDefault();
		 		thisClass.objClubAlbumList_List.reset();
		 		
		 		thisClass.objComm.setClubAlbumListRequest("검색종류",thisClass.objClubSType.getValue());
		 		thisClass.objComm.setClubAlbumListRequest("검색어",thisClass.objClubSText.getValue());
		 		thisClass.objComm.setClubAlbumListRequest("페이지",1);
		 		thisClass.objComm.getClubAlbumList();
		 	});		 	
		 	
		 	//메뉴
		 	$("section#club_album_list nav ul li a:eq(0)").click(function(event){
		 		event.preventDefault();
		 		thisClass.goNavi();
		 	});
		 	
		 	//알림
		 	$("section#club_album_list nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("../inc/info_booking.html","slide",true);	
		 	});
		 	
		 	//이전
		 	$("section#club_album_list header div.top_title_B div.top_left a.btn10").click(function(event){
		 		event.preventDefault();
		 		_gf.CLUB_DATA = {
					"동호회키": thisClass.club_seq	
				}
		 		$.mobile.changePage("self_club.html","slide",true);	
		 	});
		 }
		 , getParam: function(){
	    	this.club_seq = _gf.CLUB_DATA["동호회키"];
	    	if(_util.getLogin()){
	    		this.objClubAlbumList_Title.setIdx(_gf.CLUB_DATA["내글"]=="Y"?1:0);
	    	}else {
	    		this.objClubAlbumList_Title.setIdx(0);
	    		_gf.CLUB_DATA["내글"]=="N";
	    	}
	    }
	    , _role: function(){
	    		
	   }
		, goNavi: function(){			
			$.mobile.changePage("../inc/navi.html","slide",true);
		}
		, goLogin: function(){
			_gf.LOGIN_DATA.loginAfterUrl = "../club/club_album.html";
			$.mobile.changePage("../member/login.html","slide",true); 
		}
	    , spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		}
		, spinEnd: function(){			
	 		$.mobile.hidePageLoadingMsg();				
		}
	}